from web.service.LBCParser import LBCParser
from geo.models import NoSuchCity, NoSuchStreet, NoSuchLocation
from infra.logging import logger


class TatraBankaParser(LBCParser):
	'''
	classdocs
	'''

	def __init__(self, lbcategory, dataProcessor): 
		LBCParser.__init__(self, lbcategory, dataProcessor)


	def filter(self, content):
		return content
	
	
	def handle_data(self, data):
		for ln in data.split('\n'):
			if ln.find('new F') != -1:
				log = logger.getLogger()
				argv = ln.replace("'", "").split(',')
				try:
					self.setCity(argv[8])
					self.setStreet('%s %s' % (argv[5], argv[6]))
					self.createOrganization(name = u'Tatra Banka, a.s.', \
								            	url = 'http://www.tatrabanka.sk', \
								            	phone = 'Linka 24: 0850 111 100', \
												logo = 'icons/lbc/atm/tatrabank.png', \
												email = '')										
				except NoSuchCity, e:
					log.error('NoSuchCity exception caught, reason: %s' % e)
				except NoSuchStreet, e:
					log.error('NoSuchStreet exception caught, reason: %s' % e)
				except NoSuchLocation, e:
					log.error('NoSuchLocation exception caught, reason: %s' % e)
				except Exception, e:
					log.error('An exception caught, reason: %s' % e)
				
					
				self.reset__()

		
	def getId(self):
		return self.__class__.__name__
